/**
 * jims
 */
package com.jims.master.modules.doctor.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jims.master.common.persistence.DataEntity;
import com.jims.master.common.utils.DateUtils;
import com.jims.master.modules.finance.entity.PatPrepayment;
import com.jims.master.modules.nurse.entity.BedRec;
import com.jims.master.modules.sys.entity.OrgDept;
import com.jims.master.modules.sys.entity.User;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 病人在院信息Entity
 *
 * @author 赵宁
 * @version 2017-03-27
 */
public class PatVisit extends DataEntity<PatVisit> {

    private static final long serialVersionUID = 1L;
    private String patientId;        // 病人ID
    private String clinicId;//门诊ID
    private String visitNo;        // 住院号
    private int visitNumber;//住院次数
    private Date situationDate;        // 发病时间
    private String situationType;        // 病情状态
    private String hospitalSituation;        // 入院情况
    private String quarantine;        // 隔离情况
    private String diagnosis;        // 入院诊断
    private String deptAdmissionTo;        // 入院科室
    private String wardAdmissionTo;        // 入院病区
    private Date admissionDate;        // 入院日期及时间
    private String channel;        // 入院途径
    private String source;        // 入院来源
    private String deptDischargeTo;        // 出院科室
    private String wardDischargeTo;        // 出院病区
    private Date dischargeDate;        // 出院时间
    private String inFlag;        // 标识 0：在院 1：出院 2：归档
    private String deptFlag;    // 标识 0:待入 1：在科 2：科室转出 3：病区转出
    private String wardFlag;    // 标识
    private String deptStayed;        // 所在科室
    private OrgDept deptStayedEt;  //所在科室
    private String wardCode;        // 所在病区
    private Date enterDeptDate;        // 入科日期及时间
    private String qualityNurse;        // 质控护士
    private String dutyNurse;        // 责任护士
    private String doctorInCharge;        // 经治医师
    private String upperDoctor;        // 上级医生
    private String directorDoctor;        // 主任医生
    private String nursingClass;        // 护理等级
    private String prepayments;        // 预交金
    private String totalCosts;        // 计价总费用
    private String totalCharges;        // 应付费用
    private String settledIndicator;        // 出院结算标记
    private PatVisitIndex patVisitIndex;//
    private LiveRequisition liveRequisition;
    private String days;//住院天数
    private List<String> ids = new ArrayList<String>();
    private User doctorInChargeEt;// 经治医师
    private User upperDoctorEt;// 上级医生
    private User directorDoctorEt;// 主任医师
    private User dutyNurseEt;// 责任护士
    private User qualityNurseEt;// 责任护士
    private String bedNo;
    private BedRec bedRec;//床位
    private List<PatPrepayment> patPrepayments;
    private HisDiagnosis hisDiagnosis;
    private PatPrepayment patPrepayment;
    private String zhuyuanTians;
    private String startDate;
    private String endDate;
    private Double price;
    private String chargeType;
    private Date enterWardDate;
    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public PatPrepayment getPatPrepayment() {
        return patPrepayment;
    }

    public void setPatPrepayment(PatPrepayment patPrepayment) {
        this.patPrepayment = patPrepayment;
    }

    public HisDiagnosis getHisDiagnosis() {
        return hisDiagnosis;
    }

    public void setHisDiagnosis(HisDiagnosis hisDiagnosis) {
        this.hisDiagnosis = hisDiagnosis;
    }

    public OrgDept getDeptStayedEt() {
        return deptStayedEt;
    }

    public void setDeptStayedEt(OrgDept deptStayedEt) {
        this.deptStayedEt = deptStayedEt;
    }

    public String getDeptFlag() {
        return deptFlag;
    }

    public void setDeptFlag(String deptFlag) {
        this.deptFlag = deptFlag;
    }

    public String getWardFlag() {
        return wardFlag;
    }

    public void setWardFlag(String wardFlag) {
        this.wardFlag = wardFlag;
    }

    public LiveRequisition getLiveRequisition() {
        return liveRequisition;
    }

    public void setLiveRequisition(LiveRequisition liveRequisition) {
        this.liveRequisition = liveRequisition;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }


    public PatVisit() {
        super();
        this.inFlag="0";
    }

    public PatVisit(String id) {
        super(id);
    }

    @Length(min = 1, max = 64, message = "病人ID长度必须介于 1 和 64 之间")
    public String getPatientId() {
        return patientId;
    }

    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }

    @Length(min = 1, max = 100, message = "住院号长度必须介于 1 和 100 之间")
    public String getVisitNo() {
        return visitNo;
    }

    public void setVisitNo(String visitNo) {
        this.visitNo = visitNo;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date getSituationDate() {
        return situationDate;
    }

    public void setSituationDate(Date situationDate) {
        this.situationDate = situationDate;
    }

    @Length(min = 0, max = 1, message = "病情状态长度必须介于 0 和 1 之间")
    public String getSituationType() {
        return situationType;
    }

    public void setSituationType(String situationType) {
        this.situationType = situationType;
    }

    @Length(min = 0, max = 1, message = "入院情况长度必须介于 0 和 1 之间")
    public String getHospitalSituation() {
        return hospitalSituation;
    }

    public void setHospitalSituation(String hospitalSituation) {
        this.hospitalSituation = hospitalSituation;
    }

    @Length(min = 0, max = 1, message = "隔离情况长度必须介于 0 和 1 之间")
    public String getQuarantine() {
        return quarantine;
    }

    public void setQuarantine(String quarantine) {
        this.quarantine = quarantine;
    }

    @Length(min = 0, max = 500, message = "入院诊断长度必须介于 0 和 500 之间")
    public String getDiagnosis() {
        return diagnosis;
    }

    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }

    @Length(min = 0, max = 64, message = "入院科室长度必须介于 0 和 64 之间")
    public String getDeptAdmissionTo() {
        return deptAdmissionTo;
    }

    public void setDeptAdmissionTo(String deptAdmissionTo) {
        this.deptAdmissionTo = deptAdmissionTo;
    }

    @Length(min = 0, max = 64, message = "入院病区长度必须介于 0 和 64 之间")
    public String getWardAdmissionTo() {
        return wardAdmissionTo;
    }

    public void setWardAdmissionTo(String wardAdmissionTo) {
        this.wardAdmissionTo = wardAdmissionTo;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "入院日期及时间不能为空")
    public Date getAdmissionDate() {
        return admissionDate;
    }

    public void setAdmissionDate(Date admissionDate) {
        this.admissionDate = admissionDate;
    }

    @Length(min = 0, max = 1, message = "入院来源长度必须介于 0 和 1 之间")
    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    @Length(min = 0, max = 64, message = "出院科室长度必须介于 0 和 64 之间")
    public String getDeptDischargeTo() {
        return deptDischargeTo;
    }

    public void setDeptDischargeTo(String deptDischargeTo) {
        this.deptDischargeTo = deptDischargeTo;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date getDischargeDate() {
        return dischargeDate;
    }

    public void setDischargeDate(Date dischargeDate) {
        this.dischargeDate = dischargeDate;
    }

    @Length(min = 1, max = 1, message = "标识长度必须介于 1 和 1 之间")
    public String getInFlag() {
        return inFlag;
    }

    public void setInFlag(String inFlag) {
        this.inFlag = inFlag;
    }

    @Length(min = 0, max = 64, message = "所在科室长度必须介于 0 和 64 之间")
    public String getDeptStayed() {
        return deptStayed;
    }

    public void setDeptStayed(String deptStayed) {
        this.deptStayed = deptStayed;
    }

    @Length(min = 0, max = 64, message = "所在病区长度必须介于 0 和 64 之间")
    public String getWardCode() {
        return wardCode;
    }

    public void setWardCode(String wardCode) {
        this.wardCode = wardCode;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date getEnterDeptDate() {
        return enterDeptDate;
    }

    public void setEnterDeptDate(Date enterDeptDate) {
        this.enterDeptDate = enterDeptDate;
    }

    @Length(min = 0, max = 64, message = "质控护士长度必须介于 0 和 64 之间")
    public String getQualityNurse() {
        return qualityNurse;
    }

    public void setQualityNurse(String qualityNurse) {
        this.qualityNurse = qualityNurse;
    }

    @Length(min = 0, max = 64, message = "责任护士长度必须介于 0 和 64 之间")
    public String getDutyNurse() {
        return dutyNurse;
    }

    public void setDutyNurse(String dutyNurse) {
        this.dutyNurse = dutyNurse;
    }

    @Length(min = 0, max = 64, message = "经治医师长度必须介于 0 和 64 之间")
    public String getDoctorInCharge() {
        return doctorInCharge;
    }

    public void setDoctorInCharge(String doctorInCharge) {
        this.doctorInCharge = doctorInCharge;
    }

    @Length(min = 0, max = 64, message = "上级医生长度必须介于 0 和 64 之间")
    public String getUpperDoctor() {
        return upperDoctor;
    }

    public void setUpperDoctor(String upperDoctor) {
        this.upperDoctor = upperDoctor;
    }

    @Length(min = 0, max = 64, message = "主任医生长度必须介于 0 和 64 之间")
    public String getDirectorDoctor() {
        return directorDoctor;
    }

    public void setDirectorDoctor(String directorDoctor) {
        this.directorDoctor = directorDoctor;
    }

    @Length(min = 0, max = 64, message = "护理等级长度必须介于 0 和 64 之间")
    public String getNursingClass() {
        return nursingClass;
    }

    public void setNursingClass(String nursingClass) {
        this.nursingClass = nursingClass;
    }

    public String getPrepayments() {
        return prepayments;
    }

    public void setPrepayments(String prepayments) {
        this.prepayments = prepayments;
    }

    @Length(min = 0, max = 1, message = "出院结算标记长度必须介于 0 和 1 之间")
    public String getSettledIndicator() {
        return settledIndicator;
    }

    public void setSettledIndicator(String settledIndicator) {
        this.settledIndicator = settledIndicator;
    }

    public PatVisitIndex getPatVisitIndex() {
        return patVisitIndex;
    }

    public void setPatVisitIndex(PatVisitIndex patVisitIndex) {
        this.patVisitIndex = patVisitIndex;
    }

    public BedRec getBedRec() {
        return bedRec;
    }

    public void setBedRec(BedRec bedRec) {
        this.bedRec = bedRec;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public List<PatPrepayment> getPatPrepayments() {
        return patPrepayments;
    }

    public void setPatPrepayments(List<PatPrepayment> patPrepayments) {
        this.patPrepayments = patPrepayments;
    }

    public User getDoctorInChargeEt() {
        return doctorInChargeEt;
    }

    public void setDoctorInChargeEt(User doctorInChargeEt) {
        this.doctorInChargeEt = doctorInChargeEt;
    }

    public User getUpperDoctorEt() {
        return upperDoctorEt;
    }

    public void setUpperDoctorEt(User upperDoctorEt) {
        this.upperDoctorEt = upperDoctorEt;
    }

    public User getDirectorDoctorEt() {
        return directorDoctorEt;
    }

    public void setDirectorDoctorEt(User directorDoctorEt) {
        this.directorDoctorEt = directorDoctorEt;
    }

    public User getDutyNurseEt() {
        return dutyNurseEt;
    }

    public void setDutyNurseEt(User dutyNurseEt) {
        this.dutyNurseEt = dutyNurseEt;
    }

    public User getQualityNurseEt() {
        return qualityNurseEt;
    }

    public void setQualityNurseEt(User qualityNurseEt) {
        this.qualityNurseEt = qualityNurseEt;
    }

    public String getZhuyuanTians(){
        if(admissionDate != null && dischargeDate != null){
            Double tianshu = DateUtils.getDistanceOfTwoDate2(admissionDate, dischargeDate);
            String zytianshu = String.valueOf(tianshu);
            return zytianshu.substring(0, zytianshu.lastIndexOf("."));
        }
        if(zhuyuanTians ==null ||  "".equals(zhuyuanTians) || zhuyuanTians.equals("0")) {
            if (admissionDate != null && dischargeDate != null) {
                Double tianshu = DateUtils.getDistanceOfTwoDate(admissionDate, dischargeDate);
                String zytianshu = String.valueOf(tianshu);
                return zytianshu.substring(0, zytianshu.lastIndexOf("."));
            }
        }
        if(admissionDate!=null){
            return String.valueOf(DateUtils.pastDays(admissionDate));
        }
        return zhuyuanTians;
    }
    public void setZhuyuanTians(String zhuyuanTians){
         this.zhuyuanTians = zhuyuanTians;
    }

    public String getBedNo() {
        return bedNo;
    }

    public void setBedNo(String bedNo) {
        this.bedNo = bedNo;
    }

    public String getWardDischargeTo() {
        return wardDischargeTo;
    }

    public void setWardDischargeTo(String wardDischargeTo) {
        this.wardDischargeTo = wardDischargeTo;
    }

    public Date getEnterWardDate() {
        return enterWardDate;
    }

    public void setEnterWardDate(Date enterWardDate) {
        this.enterWardDate = enterWardDate;
    }

    public String getDays() {
        return days;
    }

    public void setDays(String days) {
        this.days = days;
    }

    public List<String> getIds() {
        return ids;
    }

    public void setIds(List<String> ids) {
        this.ids = ids;
    }

    public String getChargeType() {
        return chargeType;
    }

    public void setChargeType(String chargeType) {
        this.chargeType = chargeType;
    }

    public int getVisitNumber() {
        return visitNumber;
    }

    public void setVisitNumber(int visitNumber) {
        this.visitNumber = visitNumber;
    }

    public String getTotalCosts() {
        return totalCosts;
    }

    public void setTotalCosts(String totalCosts) {
        this.totalCosts = totalCosts;
    }

    public String getTotalCharges() {
        return totalCharges;
    }

    public void setTotalCharges(String totalCharges) {
        this.totalCharges = totalCharges;
    }

    public String getClinicId() {
        return clinicId;
    }

    public void setClinicId(String clinicId) {
        this.clinicId = clinicId;
    }
}